﻿using Microsoft.Extensions.DependencyInjection;
using Service.Infrastructure.Cache;
using Service.Infrastructure.Interfaces;

namespace Service.API
{
    public static class InfrastructureServiceExtensions
    {
        public static void UseInfrastructure(this IServiceCollection services)
        {
            services.AddSingleton<ICacheManager, CacheManager>();
            //services.AddSingleton<IJwtHelper, JwtHelper>((provider) =>
            //{
            //    var option = provider.GetRequiredService<JwtOption>();
            //    var helper = new JwtHelper(option);
            //    helper.JwtUserCacheName = "User";
            //    helper.JwtPermissionCacheName = "Permission";
            //    return helper;
            //});
            //services.AddTransient((IServiceProvider provider) =>
            //{
            //    var configuration = provider.GetRequiredService<IConfiguration>();
            //    var option = new JwtOption();

            //    option.SecretKey = configuration.GetSection("jwtOption:secret").Value;
            //    option.Issuer = configuration.GetSection("jwtOption:issuer").Value;
            //    option.Audience = configuration.GetSection("jwtOption:audience").Value;

            //    if (action != null)
            //    {
            //        action(option);
            //    }

            //    return option;
            //});
        }
    }
}
